package com.future.mayi.activity;

import android.content.Intent;
import android.text.TextUtils;
import android.widget.EditText;
import android.widget.TextView;

import com.future.baselib.entity.DefaultResponse;
import com.future.baselib.utils.ApiCst;
import com.future.baselib.utils.HttpRequest;
import com.future.mayi.R;
import com.future.mayi.app.App;

import butterknife.BindView;
import butterknife.OnClick;

public class AccountApplyActivity extends BaseTitleActivity {

    @BindView(R.id.edt_name)
    EditText edtName;
    @BindView(R.id.edt_phone)
    EditText edtPhone;
    @BindView(R.id.edt_wechat)
    EditText edtWechat;
    @BindView(R.id.tv_enter)
    TextView tvEnter;

    @Override
    protected void initTopBar() {
        initBack();
        getTitleText().setText("申请成为团长");
    }

    @Override
    protected void initLayout() {
        setContentView(R.layout.activity_account_apply);
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initDates() {

    }

    @Override
    protected void initListener() {

    }


    @OnClick(R.id.tv_enter)
    public void onClick() {
        String name = edtName.getText().toString();
        if (TextUtils.isEmpty(name)) {
            toast("请输入真实姓名");
            return;
        }
        String phone = edtPhone.getText().toString();
        if (TextUtils.isEmpty(phone)) {
            toast("请输入手机号");
            return;
        }
        String wechat = edtWechat.getText().toString();
        if (TextUtils.isEmpty(wechat)) {
            toast("请输入微信号");
            return;
        }
        new HttpRequest<DefaultResponse>()
                .with(getActivity())
                .setApiCode(ApiCst.myApply)
                .addParam("token", App.getToken(mContext))
                .addParam("realname", name)
                .addParam("phone", phone)
                .addParam("wx_number", wechat)
                .setListener(new HttpRequest.OnNetworkListener<DefaultResponse>() {
                    @Override
                    public void onSuccess(DefaultResponse response) {
                        startActivity(new Intent(mContext, AccountStateActivity.class));
                        finish();
                    }

                    @Override
                    public void onFail(String message, DefaultResponse response) {

                    }
                }).start(new DefaultResponse());

    }
}
